import React, { Component } from 'react';
// import qs from 'query-string';

export default class index extends Component {
  state = {
    data: [
      {
        id: '001',
        name: '张三',
      },
      {
        id: '002',
        name: '李四',
      },
      {
        id: '003',
        name: '王五',
      },
    ],
  };
  render() {
    // 路由 props 传参
    // const { id } = this.props.match.params;

    // 路由 search 传参
    // const { id } = qs.parse(this.props.location.search.substring(1))


    // 路由 state 传参
    const { id } = this.props.location.state
    console.log(this.props)
    const findRet = this.state.data.find((item) => item.id === id) || {};
    return (
      <ul>
        <li>
          <a href='/message1'>id: {findRet.id} </a>&nbsp;&nbsp;
        </li>
        <li>
          <a href='/message2'>名称: {findRet.name} </a>&nbsp;&nbsp;
        </li>
        <li>
          <a href='/message/3'>内容： id: {findRet.id},名称：{findRet.name}</a>&nbsp;&nbsp;
        </li>
      </ul>
    );
  }
}
